---
title: "Row Dragging Customisation"
---

There are some options that can be used to customise the Row Drag experience, so it has a better integration with your application.

## Entire Row Dragging

When using row dragging it is also possible to reorder rows by clicking and dragging anywhere on the row without the need for a drag handle by enabling the `rowDragEntireRow` grid option.

{% gridExampleRunner title="Entire Row Dragging" name="entire-row-dragging" /%}

The example above demonstrates entire row dragging with [Multi-Row Dragging](./row-dragging-managed/#multi-row-dragging). Note the following:

* Reordering rows by clicking and dragging anywhere on a row is possible as `rowDragEntireRow` is enabled.
* Multiple rows can be selected and dragged as `rowDragMultiRow` is also enabled with `rowSelection.mode = 'multiRow'`.
* Row Drag Managed is being used, but it is not a requirement for `Entire Row Dragging`.

To enable entire row dragging, set the `rowDragEntireRow` property to `true` in the `gridOptions` as shown below:

```{% frameworkTransform=true %}
const gridOptions = {
    columnDefs: [
        { field: 'country' },
        { field: 'year' },
        { field: 'sport' },
        { field: 'total' }
    ],
    // allows rows to be dragged without the need for drag handles
    rowDragEntireRow: true
}
```

{% warning %}
[Cell Selection](./cell-selection/) is not supported when `rowDragEntireRow` is enabled.
{% /warning %}

## Custom Row Drag Text

When a row drag starts, a "floating" DOM element is created to indicate which row is being dragged. By default, this DOM element will contain the same value as the cell that started the row drag. It's possible to override that text by using the `gridOptions.rowDragText` callback.

{% gridExampleRunner title="Row Drag With Custom Text" name="custom-drag-text" /%}

The example above shows dragging with custom text. The following can be noted:

* When you drag a row of the year 2012, the `rowDragText` callback will add **(London Olympics)** to the floating drag element.

To enable custom row drag text, set the `rowDragText` callback in the `gridOptions` as shown below:

```{% frameworkTransform=true %}
const gridOptions = {
    columnDefs: [
        {
            field: 'athlete',
            rowDrag: true
        }, {
            field: 'country'
        }
    ],
    rowDragText: (params, dragItemCount) => {
        return (
            dragItemCount > 1
                ? (dragItemCount + ' items')
                : params.defaultTextValue + ' is'
        ) + ' being dragged...';
    }
}
```

{% apiDocumentation source="grid-options/properties.json" section="rowDragging" names=["rowDragText"] /%}


## Custom Row Drag Text with Multiple Draggers

If the grid has more than one column set with `rowDrag=true`, the `rowDragText` callback can be set in the `colDef`.

{% gridExampleRunner title="Row Drag With Custom Text and Multiple Draggers" name="custom-drag-multiple-draggers" /%}

The example above shows dragging with custom text and multiple column draggers. The following can be noted:

* When you drag a row with a year of 2012 by the country row dragger, the `rowDragText` callback will add **(London Olympics)** to the floating drag element.

* When you drag the row by the athlete row dragger, the `rowDragText` callback in the `gridOptions` will be overridden by the one in the `colDef` and will display the number of **athletes selected**.

To enable custom row drag text per column dragger, set the `rowDragText` callback in the `colDef` as shown below:

```{% frameworkTransform=true %}
const gridOptions = {
    columnDefs: [
        {
            field: 'athlete',
            rowDrag: true
        }, {
            field: 'country',
            rowDrag: true,
            rowDragText: (params, dragItemCount) => {
                const suffix = dragItemCount == 1 ? 'country' : 'countries';
                return `Dragging ${dragItemCount} ${suffix}`;
            }
        }
    ],
    rowDragText: (params, dragItemCount) => {
        return (
            dragItemCount > 1
                ? (dragItemCount + ' items')
                : params.defaultTextValue + ' is'
        ) + ' being dragged...';
    }
}
```

## Row Dragger inside Custom Cell Renderers

Due to the complexity of some applications, it could be handy to render the Row Drag Component inside of a Custom Cell Renderer. This can be achieved by using the `registerRowDragger` method in the [ICellRendererParams](./component-cell-renderer/).

{% gridExampleRunner title="Row Drag With Custom Cell Renderer" name="dragger-inside-custom-cell-renderer" /%}

The example above shows a custom cell renderer using the`registerRowDragger` callback to render the Row Dragger inside itself.

* When you hover the cells, an arrow will appear, and this arrow can be used to **drag** the rows.

To register a custom row dragger inside a custom cell renderer, use the `registerRowDragger` method from the `ICellRendererParams` as shown below:

{% if isFramework("javascript") %}
```js
// your custom cell renderer init code
const rowDragger = document.createElement('div')
this.eGui.appendChild(rowDragger);

// register it as a row dragger
params.registerRowDragger(rowDragger);
```
{% /if %}

{% if isFramework("angular") %}
```js
// your custom cell renderer code
@ViewChild('myref') myRef;

agInit(params: ICellRendererParams): void {
    this.cellRendererParams = params;
}

ngAfterViewInit() {
    this.cellRendererParams.registerRowDragger(this.myRef.nativeElement);
}
```
{% /if %}

{% if isFramework("react") %}
```js
// your custom cell renderer code

// this will hold the reference to the element you want to act as row dragger.
const myRef = useRef(null);

useEffect(() => {
    props.registerRowDragger(myRef.current!);
});
```
{% /if %}

{% if isFramework("vue") %}
```js
// your custom cell renderer code
mounted() {
    this.params.registerRowDragger(this.$refs.myRef);
}
```
{% /if %}

{% warning %}
When using `registerRowDragger` you should **not** set the property `rowDrag=true` in the Column Definition.
Doing that will cause the cell to have two row draggers.
{% /warning %}

## Full Width Row Dragging

It is possible to drag [Full Width Rows](./full-width-rows/) by registering a [Custom Row Dragger](#row-dragger-inside-custom-cell-renderers).

{% gridExampleRunner title="Row Drag with Full Width Rows" name="dragger-inside-full-width-row" /%}

In the example above, only the full width rows are draggable.

## Row Dragger with Custom Start Drag Pixels

By default, the drag event only starts after the **Row Drag Element** has been dragged by `4px`, but sometimes it might be useful to start the drag with a different drag threshold.
For example, start dragging as soon as the `mousedown` event happens (dragged by `0px`). For that reason, the `registerRowDragger` takes a second parameter to specify the number of pixels that will start the drag event.

{% gridExampleRunner title="Row Drag With Custom Start Drag Pixels" name="dragger-inside-custom-start-drag-pixels" /%}

In the example above, the drag event starts as soon as `mousedown` is fired.

{% partial file="../shared-partials/_drag-and-drop-image-component.mdoc" /%}

## Next Up
Continue to the next section to learn about [Row Dragging to an External DropZone](./row-dragging-to-external-dropzone).